<!DOCTYPE html>
<html lang="zh_CN" class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>新增信息</title>
    <header th:replace="header::html"></header>
</head>
<body>

<div class="x-body">
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form">
                <input id='hiddenId' type='hidden' th:value='${clientMenu.id}' name='id'/>
                <div class='layui-form-item'>
                    <label class='layui-form-label'><span class='x-red'>*</span>菜单名</label>
                    <div class='layui-input-inline'>
                        <input th:value='${clientMenu.title}' class='layui-input' placeholder='请输入菜单名' type='text'
                               name='title' id='titleName' lay-verify='required'>
                    </div>
                </div>
                <div class='layui-form-item'>
                    <label for='href' class='layui-form-label'><span class='x-red'>*</span>访问地址</label>
                    <div class='layui-input-inline'>
                        <input th:value='${clientMenu.href}' class='layui-input' type='text'
                               name='href' id='href' lay-verify='required'>
                    </div>
                </div>
                <div class='layui-form-item'>
                    <label for='sort' class='layui-form-label'><span class='x-red'>*</span>排序</label>
                    <div class='layui-input-inline'>
                        <input th:value='${clientMenu.sort}' class='layui-input' type='number'
                               name='sort' id='sort' lay-verify='required'>
                    </div>
                </div>
                <div class='layui-form-item'>
                    <label class='layui-form-label'><span class='x-red'>*</span>状态</label>
                    <div class='layui-input-inline'>
                        <select id="selectType" name="status" lay-filter="status" th:value="${clientMenu.status}">
                            <option value="1">有效</option>
                            <option value="0">无效</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <button class="layui-btn layui-btn-danger" lay-filter="add" lay-submit="">
                        <i class="iconfont">&#xe6ad;</i>立即提交
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer
        //监听提交
        form.on('submit(add)', function (data) {
            $.ajax({
                url: "/client/saveOrUpdate",
                type: "POST",
                data: data.field,
                dataType: 'json',
                success: function (result) {
                    if (result.code == 500 || result.code == 5000100 || result.code == 5000101 || result.code == 5000102) {
                        layer.alert(result.msg);
                    } else {
                        layer.alert("设置成功", {icon: 6}, function () {
                            xadmin.close();
                            xadmin.father_reload();
                        });
                    }
                }
            });
            return false;
        });
        initSelectType();
    });
</script>
</body>
</html>
